﻿<!---
 
  Copyright (c) 2010, Cristian Costantini - cristian@millemultimedia.it
  
  FileManager is licensed under the terms of the Open Source GPL 3.0 license. 
	
	http://www.gnu.org/licenses/gpl.html
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--->

<cfcomponent output="false">

    <cfsetting showdebugoutput="false" />
	
    <cfprocessingdirective pageencoding="utf-8" />
    <cfcontent type="text/html; charset=utf-8" />
    <cfset SetEncoding("url", "utf-8")>
    <cfset SetEncoding("form", "utf-8")>
    
	<cfset this.applicationTimeout = createTimeSpan(0,2,0,0) />
	<cfset this.sessionTimeout = createTimeSpan(0,0,40,0) />
	<cfset this.clientManagement = false />
	<cfset this.loginStorage = "session" />
	<cfset this.sessionManagement = true />
	
	<cfset this.version = "1.0.269" />
	
	<cfset libs = '#getDirectoryFromPath(getCurrentTemplatePath())#lib' />
	
	<cfset this.mappings["/coldspring"] = libs & "/coldspring/" />
	
	<cffunction name="onApplicationStart" returnType="boolean" output="false">
		<cfscript>
		var bootstrap = "";
		bootstrap = createObject('component','fileManager.loading.FileManagerBootstrapper').init( this );
		
		bootstrap.run();
		</cfscript>		
		<cfreturn true />
	</cffunction>
	
	<cffunction name="storeCore" returnType="void" output="false">
		<cfargument name="core" required="true" />
		<cfset application.fileManager = arguments.core.getBean('fileManager') />
	</cffunction>
	
	<cffunction name="storeConfig" returnType="void" output="false">
		<cfargument name="config" required="true" />
		<cfset application.config = arguments.config />
	</cffunction>
	
	<cffunction name="onRequestStart" returnType="boolean" output="false">
		<cfargument name="thePage" type="string" required="true" />
		<cfif structKeyExists(url,'reload')>
			<cfset onApplicationStart() />
			<cfset onSessionStart() />
		</cfif>
		<cfset request.fileManager = application.fileManager />
		<cfreturn true />
	</cffunction>
	
	<cffunction name="onSessionStart" returnType="void" output="false">
		<cfset var objConfig = makeConfig() />
		
        <cfset session.config = objConfig />
	</cffunction>
	
	<cffunction name="onSessionEnd" returnType="void" output="false">
        <cfset structDelete( session, 'config' ) />
	</cffunction>
	
	<cffunction name="makeConfig" access="private" returntype="Component" output="false" >
		<cfset var i = 0 />
		<cfset var obj = createObject( 'component', 'fileManager.metadata.Config' ).init() />
		
		<cfloop from="1" to="#arrayLen( application.config )#" index="i">
			<cfset obj[ application.config[i].XmlAttributes['name'] ] = application.config[i].XmlAttributes['value'] />
		</cfloop>
		
		<cfreturn obj />
	</cffunction>
	
</cfcomponent>